#ifndef __PLAYER_H__
#define __PLAYER_H__

#include <utility>

#include "common.h"


struct FightInfo{
    int atk;
    int def;
    int max_hp;
    int cur_hp;
    int max_mp;
    int cur_mp;
    int speed;
    int critical_rate;
    int critical_damage;
    int evasion_rate;
    int hit_rate;

    FightInfo(){
        atk = 0;
        def = 0;
        max_hp = 0;
        cur_hp = 0;
        max_mp = 0;
        cur_mp = 0;
        speed = 0;
        critical_rate = 0;
        critical_damage = 0;
        evasion_rate = 0;
        hit_rate = 0;
    }

    void Init(
        int tatk,
        int tdef,
        int tmax_hp,
        int tcur_hp,
        int tmax_mp,
        int tcur_mp,
        int tspeed,
        int tcritical_rate,
        int tcritical_damage,
        int tevasion_rate,
        int thit_rate)
    {
        atk = tatk;
        def = tdef;
        max_hp = tmax_hp;
        cur_hp = tcur_hp;
        max_mp = tmax_mp;
        cur_mp = tcur_mp;
        speed = tspeed;
        critical_rate = tcritical_rate;
        critical_damage = tcritical_damage;
        evasion_rate = tevasion_rate;
        hit_rate = thit_rate;
    }
};

struct Position{
    int pos_x;
    int pos_y;
    EDirection direction;
};
struct SceneInfo{
    int scene_id;
    int scene_gid;
    Position position;
};

class Player
{
private:
    /* data */
public:
    Player(int player_id, int socket_fd);
    ~Player();

    inline void SetMapInfo(int current_map_type_id, int current_map_unique_id){
        current_map_type_id_ = current_map_type_id;
        current_map_unique_id_ = current_map_unique_id;
    }
    inline void SetPos(int pos_x, int pos_y){
        pos_x_ = pos_x;
        pos_y_ = pos_y;
    }
    inline std::pair<int, int> GetPos(){
        return std::pair<int, int>(pos_x_, pos_y_);
    }

    inline int GetPlayerID(){
        return player_id_;
    }
    inline int GetSocketFd(){
        return socket_fd_;
    }

    inline int GetCurrentMapTypeID(){
        return current_map_type_id_;
    }
    inline int GetCurrentMapUniqueID(){
        return current_map_unique_id_;
    }

    inline void SetSpeed(int speed_x, int speed_y){
        speed_x_ = speed_x;
        speed_y_ = speed_y;
    }
    inline int GetSpeedX(){
        return speed_x_;
    }

    inline void SetDirection(EDirection dir){
        direction_ = dir;
    }
    inline EDirection GetDirection(){
        return direction_;
    }

    inline void SetFightInfo(const FightInfo& fight_info){
        fight_info_ = std::move(fight_info);
    }

public:
    int player_id_;
    int current_map_type_id_;
    int current_map_unique_id_;
    int pos_x_;
    int pos_y_;
    int speed_x_;
    int speed_y_;
    EDirection direction_;
    FightInfo fight_info_;
    SceneInfo scene_info_;

    int socket_fd_;
};



#endif  // __PLAYER_H__